home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / cp1.zip / KEY1.C < prev    next >
C/C++ Source or Header  |  1993-06-14  |  3KB  |  88 lines

  1. ===========================================================================
  2.  BBS: The Abacus * HST/DS * Potterville MI
  3. Date: 06-12-93 (11:07)             Number: 264
  4. From: BILL LINDSAY                 Refer#: NONE
  5.   To: ALL                           Recvd: NO  
  6. Subj: Keyboard info         1/       Conf: (36) C Language
  7. ---------------------------------------------------------------------------
  8. /*
  9.   Several people of late have requested code to determine keyboard
  10.   information.  Here is some code that displays bios information
  11.   to the user.  scope: IBM compatible PC compatible bios '86 type
  12.   processor.
  13. */
  14.            /* This code hereby consigned to the    */
  15.            /* public domain by Bill Lindsay, this  */
  16.            /*         june 12. 1993.               */
  17.  
  18.  
  19. #include <dos.h>
  20. #include <stdio.h>
  21.  
  22. int board_type ();
  23. int wait_for_key ();
  24. void get_the_key (char *keys, unsigned char *togl);
  25.  
  26. union REGS intregs;
  27. int is_enhanced = 1; /* board_type() changes this to 0 if  */
  28.                      /* keyboard is not enhanced.          */
  29.  
  30. main()
  31.  {
  32.    unsigned char codes[2];  /* codes[0] = scancode    */
  33.                             /* codes[1] = character   */
  34.    unsigned char shift[2];  /* shift[] = shift status */
  35.    unsigned char mask;
  36.    int i;
  37.  
  38.    char *togles1[] =
  39.      {"r-Sh","l-Sh","Ctrl","Alt_","Scrl","Num_","CAPS","Ins_"};
  40.  
  41.    char *togles2[] =  {"\b\bl-","\b\br-"};
  42.  
  43.    is_enhanced = board_type ();
  44.  
  45.    do {
  46.      get_the_key (codes, shift);    /* Return by reference */
  47.      printf ("Scancode == \'\\x%02X\'.  ", (int) codes[0]);
  48.  
  49.      printf ("Character == \'%c\'.   ascii \'\\x%02X\'.\n",
  50.       (codes[1] == '\x0d') ? (' ') : (codes[1]),
  51.       (int) codes[1]);
  52.      for (i=7, mask = '\x01'; i >= 0; i--)  {
  53.        if (i == 2)
  54.          {                         /* left or right Ctrl */
  55.          printf("%s",((shift[1] & '\x01') ?
  56.                       (togles2[0])        :
  57.                       (shift[1] & '\x04') ?
  58.                       (togles2[1]) : ("")));
  59.          }
  60.  
  61.        else if (i == 3)
  62.          {                          /* left or right Alt */
  63.          printf("%s",((shift[1] & '\x02') ?
  64.                       (togles2[0])        :
  65.                       (shift[1] & '\x08') ?
  66.                       (togles2[1]) : ("")));
  67.          }
  68.        printf ("%s____", (shift[0] & (mask << i)) ?
  69.                          (togles1[i]) : ("____"));
  70.        } /* for loop */
  71.  
  72.      printf ("\nKeyboard is%s enhanced.  \"Q\" to quit.\n\n",
  73.       (is_enhanced) ? ("") : (" not"));
  74.  
  75.      }while (!(toupper(codes[1]) == 'Q'));
  76.    exit(0);
  77.  }
  78. ___----------------------------8<------------------------------------
  79. >>> Continued to next message
  80.  
  81.  * SLMR 2.1a *
  82.  
  83. --- Maximus 2.01wb
  84.  * Origin: LIFELINE BBS - Edmonton, Ab, Canada! V32b (403)481-4977 (1:342/51)
  85. SEEN-BY: 1/211 11/2 4 13/13 101/1 108/89 109/25 110/69 114/5 123/19 124/1
  86. SEEN-BY: 153/752 154/40 77 157/110 159/100 125 430 575 950 203/23 209/209
  87. SEEN-BY: 261/1023 280/1 390/1 396/1 5 15 2270/1 2430/1 2440/5 3603/20
  88.